// $().ready(function() {
//     $(".tab-menu li").click(function() {
//         //通过 .index()方法获取元素下标，从0开始，赋值给某个变量
//         var _index = $(this).index();
//         console.log(_index)
//             //让内容框的第 _index 个显示出来，其他的被隐藏
//         $("section>div").eq(_index).show().siblings().hide();
//         //改变选中时候的选项框的样式，移除其他几个选项的样式
//         $(this).addClass("change").siblings().removeClass("change");
//     });
// });
// var ids = [];
$.ajax({
    url: cepingApi,
    type: 'get',
    success: function(res) {

        console.log(res, 18)
        let tmp = res;

        let html = "";
        $(function() {
            $.each(tmp, function(i, v) {
                html +=
                    `
                <li class="${tmp[i].id}"><a href="#">${tmp[i].testType}</a></li>
              
                `


            })
            $(".tou").html(html);

            $(".tou li").click(function() {
                let iid = this.className
                $.ajax({
                    url: listApi,
                    type: "get",
                    data: {
                        id: iid
                    },
                    success: function(res) {
                        console.log(res)
                        let tmp = res;
                        let html = '';
                        $(function() {
                            $.each(tmp, function(i, v) {
                                html +=
                                    `
                                <div class="title">
                                <div class="touxiang"><img src="${tmp[i].headUrl}"/></div>
                                <p>${tmp[i].name}</p>
                                <span class="iconfont icon-chakan ${tmp[i].id} yanjing"></span>
                                <span class="dianji" >${tmp[i].account}</span>
                            </div>
                            <div class="content">
                                <div class="con-left">
                                    <h4 class="shang">${tmp[i].title}</h4>
                                    <p class="xia">${tmp[i].text}</p>
                
                                </div>
                                <div class="con-right">
                                <img src="${tmp[i].imgUrl}"/>
                
                                </div>
                
                            </div>
                                `

                            })
                            $("section").html(html);
                            yan();
                        })


                    },
                    error: function(error) {
                        console.log(error)
                    }

                })
            })

        })
    },
    error: function(error) {
        console.log(error);
    }
})
$.ajax({
    url: listApi,
    type: "get",
    data: {
        id: 1
    },
    success: function(res) {
        console.log(res)
        let tmp = res;
        let html = '';
        $(function() {
            $.each(tmp, function(i, v) {
                html +=
                    `
                    <div class="title">
                    <div class="touxiang"><img src="${tmp[i].headUrl}"/></div>
                    <p>${tmp[i].name}</p>
                    <span class="iconfont icon-chakan ${tmp[i].id} yanjing" ></span>
                    <span class="dianji" >${tmp[i].account}</span>
                </div>
                <div class="content">
                    <div class="con-left">
                        <h4 class="shang">${tmp[i].title}</h4>
                        <p class="xia">${tmp[i].text}</p>
    
                    </div>
                    <div class="con-right">
                    <img src="${tmp[i].imgUrl}"/>
    
                    </div>
    
                </div>
                `

            })
            $("section").html(html)
                // yan();

        })


    },
    error: function(error) {
        console.log(error)
    }

})

function yan() {
    $(".yanjing").click(function() {
        console.log(111)
        let yid = this.className.split(" ")[2];
        console.log(yid, 9999)
        $.ajax({
            url: yanjingApi,
            type: "get",
            data: {
                id: yid
            },
            success: function(res) {

            },
            error: function(error) {
                console.log(error)
            }
        })
    })


}